package pl.lsierant.j2me.bipacz.notifications.impl;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import pl.lsierant.j2me.bipacz.notifications.INotification;
import pl.lsierant.j2me.bipacz.notifications.NotificationType;
import pl.lsierant.j2me.bipacz.persistent.DeserializationHelper;
import pl.lsierant.j2me.bipacz.persistent.IPersistent;
import pl.lsierant.j2me.bipacz.persistent.PersistentObjectType;
import pl.lsierant.j2me.bipacz.persistent.SerializationHelper;

/**
 * Default notification object. Object delegates invocation to
 * NotificationManager which uses method specified in settings as default
 * notification method.
 */
public class DefaultNotification implements INotification, IPersistent {
    public static final DefaultNotification INSTANCE = new DefaultNotification();

    // singleton
    private DefaultNotification() {
    }

    public int getNotificationType() {
        return NotificationType.BEEP;
    }

    public void run() {
        NotificationManager.getInstance().run(this);
    }

    public void initialize(DataInputStream serializedData) throws IOException {
        new DeserializationHelper(serializedData); // read version
    }

    public void serialize(DataOutputStream out) throws IOException {
        new SerializationHelper(out, this, 0);// write version
    }

    public int getPersistentObjectType() {
        return PersistentObjectType.DEFAULT_NOTIFICATION;
    }

    public String toString() {
        return "DefaultNotification []";
    }

}
